package com.lagou;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import javax.servlet.ServletException;
import java.io.File;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 3:36 下午 2021/11/15
 */
@ComponentScan()
public class SpringApplication {

    public static void  run(Class<?> annotatedClasses,String[] args){
        //1. 创建IOC容器，并刷新
        AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
        ac.register(annotatedClasses);
        ac.refresh();


        //2. 创建Tomcat
        MyTomcat.createTomcat();
        //3.将dispatcherServlet放入到ioc容器，并加载到tomcat上下文中去
        //注意：dispatcherServlet不能放在启动里，因为项目可以不是web项目，dispatcherServlet不是必要的，可以被替换掉
    }
}
